# -- coding: utf-8 --

class Solution:
    def subsets(self, nums):
        """
        :type nums: List[int]
        :rtype: List[List[int]]
        """
        res = [[]]
        for i in range(1, len(nums)+1):
            self.dfs(nums, [], res, -1, i)
        return res



    def dfs(self, nums, temp, res, index, count):
        for i in range(index+1, len(nums)):
            temp.append(nums[i])
            if len(temp) == count:
                t = temp[:]
                res.append(t)
            else:
                self.dfs(nums, temp, res, i, count)
            temp.pop()

    def subsets1(self, nums):
        """
        :type nums: List[int]
        :rtype: List[List[int]]
        """
        # 最好方式 扩容原有数组
        res = [[]]
        for num in nums:
            # 两个列表+起来 成为新的列表
            res += [item + [num] for item in res]
            print(res)
        return res


test = Solution()
test.subsets1([1, 2, 3])